﻿using System;
using System.Collections;

namespace YArchitech.HCLoad.XmlData
{
	public class WhTempl : Hashtable
	{
		public WhTempl(WallDataTemplDict wallDataTemplDict)
		{
			this.parent = wallDataTemplDict;
			this.AddWallParts();
			this.AddWhTemplMaterials();
		}

		public WallDataTemplDict Parent
		{
			get
			{
				return this.parent;
			}
			set
			{
				this.parent = value;
			}
		}

		public int ID
		{
			get
			{
				return this.nID;
			}
			set
			{
				this.nID = value;
			}
		}

		public int WhId
		{
			get
			{
				return this.nWhId;
			}
			set
			{
				this.nWhId = value;
			}
		}

		public string Name
		{
			get
			{
				return this.sName;
			}
			set
			{
				this.sName = value;
			}
		}

		public string Description
		{
			get
			{
				return this.sDescription;
			}
			set
			{
				this.sDescription = value;
			}
		}

		public string WhType
		{
			get
			{
				return this.sWhType;
			}
			set
			{
				this.sWhType = value;
			}
		}

		public int SufferId
		{
			get
			{
				return this.nSufferId;
			}
			set
			{
				this.nSufferId = value;
			}
		}

		public int AutoCalDjCrXs
		{
			get
			{
				return this.nAutoCalDjCrXs;
			}
			set
			{
				this.nAutoCalDjCrXs = value;
			}
		}

		public Hashtable WallParts
		{
			get
			{
				return this.wallParts;
			}
		}

		private void AddWallParts()
		{
			try
			{
				this.wallParts = new Hashtable();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public void AddWallPart(WallPart wallPart)
		{
			try
			{
				int partID = wallPart.PartID;
				this.wallParts.Add(partID, wallPart);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public void RemoveWallPart(int PartID)
		{
			try
			{
				this.wallParts.Remove(PartID);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public WallPart GetWallPart(int PartID)
		{
			WallPart result;
			try
			{
				result = (WallPart)this.wallParts[PartID];
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
			return result;
		}

		public Hashtable WhTemplMaterials
		{
			get
			{
				return this.whTemplMaterials;
			}
		}

		private void AddWhTemplMaterials()
		{
			try
			{
				this.whTemplMaterials = new Hashtable();
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public void AddWhTemplMaterial(WhTemplMaterial whTemplMaterial)
		{
			try
			{
				whTemplMaterial.Parent = this;
				this.nKeyID++;
				whTemplMaterial.KeyID = this.nKeyID;
				int num = this.nKeyID;
				this.whTemplMaterials.Add(num, whTemplMaterial);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public void RemoveWhTemplMaterial(int MaterialID)
		{
			try
			{
				this.whTemplMaterials.Remove(MaterialID);
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
		}

		public WhTemplMaterial GetWhTemplMaterial(int MaterialID)
		{
			WhTemplMaterial result;
			try
			{
				result = (WhTemplMaterial)this.whTemplMaterials[MaterialID];
			}
			catch (Exception ex)
			{
				throw new Exception(ex.ToString());
			}
			return result;
		}

		private WallDataTemplDict parent;

		private int nID;

		private int nWhId;

		private string sName;

		private string sDescription;

		private string sWhType;

		private int nSufferId;

		private int nAutoCalDjCrXs;

		private Hashtable wallParts;

		private Hashtable whTemplMaterials;

		private int nKeyID;
	}
}
